package com.md.common.utils.redis;

import com.md.common.utils.redis.config.RedisProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 功能描述：redis缓存操作器，完成所有redis缓存操作
 *
 * @author lujianping@oak168.com
 * @version 1.0
 * @date 2018-6-15 11:51
 * @since JDK 1.8
 */
@SuppressWarnings("unused")
public abstract class RedisOperator implements RedisOperations {

    protected static final Logger LOG = LoggerFactory.getLogger(RedisOperator.class);
    private static final int DEFAULT_MAX_REDIRECTIONS = 5;
    private String host = "127.0.0.1:7000";
    private String hosts = "127.0.0.1:7000,127.0.0.1:7001";
    private int port = 7000;
    private int expire = 0;
    private int timeout = 0;
    private String password = "";
    private int maxRedirections = DEFAULT_MAX_REDIRECTIONS;

    public int getMaxRedirections() {
        return maxRedirections;
    }

    public void setMaxRedirections(int maxRedirections) {
        this.maxRedirections = maxRedirections;
    }

    /**
     * 初始化方法
     */
    public abstract void init();

    public abstract void setRedisConfig(RedisProperties rp);

    public String getHosts() {
        return hosts;
    }

    public void setHosts(String hosts) {
        this.hosts = hosts;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getTimeout() {
        return timeout;
    }

    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getExpire() {
        return expire;
    }

    public void setExpire(int expire) {
        this.expire = expire;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public abstract void flushDB();
}